<template>
    <el-dialog :title="return_type==1?'处理退货':'退尾款'" width="400px" :visible.sync="specialIsShow">
        <div class="add-box">
            <div class="flex-center">
                <span class="span">退款金额</span>
                <el-input class="display-inline width-350" v-model="price"
                          placeholder="请填写退款金额，无退款则不填写"></el-input>
            </div>
        </div>
        <div slot="footer" class="dialog-footer">
            <el-button v-preventDbClick @click="specialIsShow=false">取 消</el-button>
            <el-button v-preventDbClick type="primary" @click="submit">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script type="text/ecmascript-6">
import request from '../common/js/request.js';
import {tool} from "../common/js/tool";

export default {
    data() {
        return {
            specialIsShow: false,
            info: '',
            price: '',
            return_type: 1
        }
    },
    methods: {
        show(info, return_type) {
            this.info = info;
            this.return_type = return_type;
            this.specialIsShow = true;
        },
        submit() {
            let txt = this.return_type == 1 ? '确定要退款吗？' : '确定要退尾款吗？';
            this.$confirm(txt, "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                let url = this.return_type == 1 ? '/manage/orderReturn/back' : '/manage/orderReturn/backLast';
                request({
                    url: url,
                    data: {order_id: this.info.id, return_price: this.price, return_type: this.return_type}
                }).then((res) => {
                    this.specialIsShow = false;
                    tool.message(res.msg, 'success', () => {
                        this.$emit('toData');
                    })
                })
            }).catch(() => {
                this.specialIsShow = false;
            });
        },
    }
};
</script>

<style lang="less" rel="stylesheet/less" scoped>
.list {
    .item2 {
        border: 1px solid #ddd;
        margin: 0 10px 10px 0;
    }
}
</style>
